package com.mhh.selary.backend.enums;

import com.google.common.collect.Lists;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;

/**
 * @author mhh
 * @date 2020-09-02 17:31:05
 */
@Getter
@AllArgsConstructor
public enum PropGroupEnum {

    /**
     *
     */
    JDBC("jdbc", "数据库") {
        @Override
        public List<PropKeyEnum> getBelong() {
            return Lists.newArrayList(PropKeyEnum.JDBC_HOST, PropKeyEnum.JDBC_SCHEMA, PropKeyEnum.JDBC_USERNAME, PropKeyEnum.JDBC_PASSWORD);
        }
    },

    REDIS("redis", "Redis") {
        @Override
        public List<PropKeyEnum> getBelong() {
            return Lists.newArrayList(PropKeyEnum.REDIS_HOST, PropKeyEnum.REDIS_PASSWORD, PropKeyEnum.REDIS_DATABASE);
        }
    },

    MONGODB("mongodb", "MongoDB") {
        @Override
        public List<PropKeyEnum> getBelong() {
            return Lists.newArrayList(PropKeyEnum.MONGODB_HOST, PropKeyEnum.MONGODB_DB);
        }
    },

    //KAFKA("kafka", "Kafka"),

    USER_DEFINED("user_defined", "自定义"),

    ;

    private String name;

    private String desc;

    public List<PropKeyEnum> getBelong() {
        return Lists.newArrayListWithCapacity(0);
    }

    public static PropGroupEnum valueBy(String name) {
        return Arrays.stream(PropGroupEnum.values()).filter(enumItem -> enumItem.getName().equals(name)).findFirst().orElse(null);
    }
}
